package org.budo.cmbc.sdk.entity;

import java.util.ArrayList;
import java.util.List;

import org.budo.xml.XmlObject;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;

/**
 * 客户账单回单结果查询响应
 * 
 * @author zq
 */
@Getter
@Setter
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
@Slf4j
public class B2eElectNoteQryResponse extends AbstractCmbcResponse {
    private static final long serialVersionUID = -7240375540578762421L;

    private List<B2eElectNoteInfo> b2eElectNoteInfoList;

    private Integer count;

    public B2eElectNoteQryResponse(String responseXml) {
        this.setResponseBody(responseXml);
        this.b2eElectNoteInfoList = new ArrayList<B2eElectNoteInfo>();

        XmlObject xDataBody = this.xDataBody(responseXml);

        if (null == xDataBody) {
            log.error("#40 xDataBody=" + xDataBody + ", responseXml=" + responseXml);
            return;
        }

        this.count = Integer.valueOf(xDataBody.getChildNodeTextContentByName("Count"));

        XmlObject xmlObject = xDataBody.getChildNodeByName("List");

        if (xmlObject != null) {
            XmlObject[] xmlObjects = xmlObject.getChildNodeArrayByName("Map");

            if (xmlObjects != null && xmlObjects.length > 0) {
                for (XmlObject xmlObj : xmlObjects) {

                    if (xmlObj != null) {
                        this.b2eElectNoteInfoList.add(new B2eElectNoteInfo(xmlObj));
                    }
                }
            }
        }
    }
}
